<?php

$mcrp = './';
include_once('functions/session.php');
include_once('functions/nanofight.php');

$head = '<link href="nano/nano.css" rel="stylesheet" media="screen" type="text/css" title="style" />
<script type="text/javascript" src="nano/nanoajax.js"></script>
<script type="text/javascript" src="nano/nanomanage.js"></script>';
include($mcrp . 'skin/default.php');
include($mcrp . 'skin/header.php');

if(!isset($_GET['id']) || !is_numeric($_GET['id']) || (int)$_GET['id'] != $_GET['id']) { header('Location: nanofight.php'); exit; }
$fight = GetFightById($_GET['id']);
if($fight === false || !array_key_exists($mcuser->id, $fight->players) || $fight->statut !== 'ready') { header('Location: nanofight.php'); exit; }

?>
<div class="mc_box">
	<h3><a href="nano.php">Nanocontest</a> :: <a href="nanofight.php">Combats</a> :: Gestion</h3>
	<?php if($mcuser->id == 0) { ?>
	<div><center><img src="img/stop-trackback.png"><br/>Vous devez être connecté pour accéder à cette page.<br />Si vous n'êtes pas encore inscrit, rendez-vous sur la page d'<a href="register.php">inscription</a>.</center></div>
	<?php } else { ?>
	<div class="mc_box_content">
		<div class="mc_banner">Soumettre un programme</div>
		<div id="nc_notif" style="visibility:hidden;"></div>
		<table id="nc_fight_manage"><tr><td><h3>Programmes enregistrés</h3><div id="nc_fight_file">Chargement...</div></td>
		<td><h3>Source</h3><br /><center><textarea id="nc_fight_prgm" spellcheck="false" readonly></textarea></center>
		<div class="nc_button" style="float:right" onclick="NanoSetFightProgram(<?php echo $fight->id; ?>);">Sélectionner</div></td>
		<td><h3>Joueurs</h3><br />
		<?php foreach($fight->players as $p) { ?>
			<div class="nc_fight_user_v"><?php echo $p[0]->name; if($p[1] == 'prgm') echo '<div class="nc_check"></div>'; ?></div>
		<?php } ?>
		</td></tr></table>
		<script type="text/javascript">NanoManageListFile();</script>
	</div>
	<?php } ?>
</div>
<?php

include($mcrp . 'skin/footer.php');

?>